//
//  PaySuccViewController.m
//  WBBaseProject
//
//  Created by 吴斌 on 2018/4/11.
//  Copyright © 2018年 吴斌. All rights reserved.
//

#import "PaySuccViewController.h"
#import "PaySuccessView.h"
@interface PaySuccViewController ()
@property (nonatomic, strong) PaySuccessView *paySuccessView;
@end

@implementation PaySuccViewController

#pragma mark - 生命周期 Life Circle
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"支付成功";
    self.view.backgroundColor = WB_RGBColor(251, 251, 251);
    [self setupUI];
}

- (void)setupUI
{
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - kNavigationBarHeight)];
    scrollView.contentSize = CGSizeMake(kScreenWidth, kScreenHeight - kNavigationBarHeight + 1);
    scrollView.bounces = YES;
    scrollView.backgroundColor = WB_RGBColor(240, 240, 240);
    [self.view addSubview:scrollView];
    [scrollView addSubview:self.paySuccessView];
    
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, self.paySuccessView.mm_bottom + 10, kScreenWidth, 100)];
    imageView.image = [UIImage imageNamed:@"轮播"];
    [scrollView addSubview:imageView];
    
}

- (NSMutableAttributedString *)setAttributeWithStr:(NSString *)money
{
    NSMutableAttributedString * firstPart = [[NSMutableAttributedString alloc] initWithString:@"¥ "];
    NSDictionary * firstAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:25],NSForegroundColorAttributeName:WB_HEX_COLOR(0x000000)};
    [firstPart setAttributes:firstAttributes range:NSMakeRange(0,firstPart.length)];
    NSMutableAttributedString * secondPart = [[NSMutableAttributedString alloc] initWithString:money];
    NSDictionary * secondAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:30],NSForegroundColorAttributeName:WB_HEX_COLOR(0x000000)};
    [secondPart setAttributes:secondAttributes range:NSMakeRange(0,secondPart.length)];
    [firstPart appendAttributedString:secondPart];
    return firstPart;
}

- (void)click:(UIButton *)sender
{
    NSLog(@"重置");
}

#pragma mark - 懒加载  Lazy Load
- (PaySuccessView *)paySuccessView
{
    if (_paySuccessView == nil) {
        _paySuccessView = [[NSBundle mainBundle] loadNibNamed:@"PaySuccessView" owner:self options:nil].firstObject;
        _paySuccessView.frame = CGRectMake(0, 0, kScreenWidth, 250);
        _paySuccessView.moneyLb.attributedText = [self setAttributeWithStr:self.moneyNum];
        
        WB_WEAKSELF;
        _paySuccessView.conti = ^{
            
            [weakSelf.navigationController popViewControllerAnimated:YES];
        };
        _paySuccessView.back = ^{
            
            [weakSelf.navigationController popToRootViewControllerAnimated:YES];
        };
    }
    return _paySuccessView;
}

@end
